<include file="Public:header" />

<div id="home">

    <div id="header">

        <div style="height:28px; padding-top:10px; background:url(__PUBLIC__/Front/images/xy.png) 10px 8px no-repeat" class="logo"><span onclick=" history.go(-1);">&nbsp;</span></div>

        <div class="shoptitle"><span>积分转赠</span></div>

        <include file="Public:righttop" />

    </div>

</div>

<include file="Public:procat" />

<style type="text/css">

    .tx-top{
        margin: 0 10px;
    }
    .tx-top p{
        padding: 15px 0;
    }
    .tx-top span{
        color: #FF0000;
    }

    .tx-content{
        padding: 0 10px;
        margin-bottom: 100px;
    }
    .tx-content li{
        border: 1px solid #eaeaea;
        border-radius: 5px;
        padding: 10px 0;
        position: relative;
        margin-bottom: 20px;
    }
    .tx-content input{
        color: #999999;
        padding-left: 10px;
        font-size: 16px;

        line-height: 40px;
    }

    .tips{
        line-height: 30px;
        color: #FF0000;
    }


    .tx-button{
        position: fixed;
        bottom:55px;
        width: 100%;
        max-width: 620px;
        min-width: 320px;
    }
    .tx-button ul{
        overflow: hidden;
        width: 100%;
    }
    .tx-button li{
        width: 46%;
    }
    .tx-button input{
        border-radius: 5px;
        padding: 10px 0;
        width: 100%;
        background: #328c09;
        color: #FFFFFF;
        font-size: 18px;
    }

</style>
<script type="text/javascript">

    var balance = "{$balance}";

//    检测会员信息正确性
    function check_member($type) {

        var id = $("input[name='ruser_id' ]").val().replace(/\s/g, "");

        if ((id == '') || (!$.isNumeric(id))) {

            jAlert('会员编码输入有误！', '警告', function () {

                return false;
            });

            return false;
        }

        if ($type == 1) {

            return true;
        }

        $.post('{:U("Member/check_member")}', {"id": id, "identify": 'store'}, function (data) {
            console.log();

            var status = data.status;

            var msg = '';

            if (status) {

                msg = '会员编号【' + data.info.id + '】,昵称【' + data.info.nickname + '】';

                jAlert(msg, '确认信息');

//                alert($("input[name='send_submit']").val());

                $("input[name='send_submit']").attr("disabled", false);
            } else {

                jAlert(data.info, '提示');
            }

        }, 'json');
    }

//检测积分信息正确性
    function  check_score() {

        var t = /^\d+(\.\d+)?$/;

        var $score = $("input[name='total' ]").val().replace(/\s/g, "");

        var aa = t.test($score);

        if (!aa || ($score <= 0)) {

            jAlert('转赠积分必须是正数!', '警告');
            return false;
        }

        return $score;
    }

//   操作button
    function  form_submit($val) {

        //表单提交
        if ($val == '1') {

//            console.log($("form").serialize());return;

            var score = $('input[name="total"]').val();

            if (!check_score(score)) {

                jAlert('转赠积分必须是正数!', '警告');
                return;
            }

            if (score > balance) {

                jAlert('余额不足!', '警告');
                return;
            }

            if (!check_member(1)) {
                return;
            }

            $('form').submit();

        } else if ($val == '2') {

            window.location.href = "{:U('Member/sendscore_list')}";
            
        } else {
            return;
        }

    }
</script>

<div id="main" style="background:#fff;">

    <header class="tx-top">

        <p>当前账户余额&nbsp;:<span>{$balance}</span></p>

    </header>

    <form id="form_sendscore"  action="{:U('Member/send_score')}"  method="post">


        <input type="hidden" name="user_id" value="{$user_id}" />

        <input type="hidden" name="member_balance" value="{$balance}" />


        <nav class="tx-content">
            <ul>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">转赠积分</span>

                    <input type="text" name="total" value="转赠数值:50"  onblur="if (value == '') {
                                value = '转赠数值:50'
                            } else {

                                return check_score();
                            }" onfocus="if (value == '转赠数值:50') {
                                        value = ''
                                    }" />

                    <!--<span style="position: absolute;right: 10px;">元</span>-->

                </li>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">收款会员</span>

                    <input type="text" name="ruser_id" value="会员编号:666"  onblur="if (value.replace(/\s/g, '') == '') {
                                value = '会员编号:666';

                            } else {

                                return check_member();
                            }" onfocus="if (value.replace(/\s/g, '') == '会员编号:666') {
                                        value = '';
                                    }" />

                    <!--                <select style="border: none; color: #999999; font-size: 16px;padding-left: 5px;">
                                        <option>河南经济广播</option>
                                        <option>河南经济广播</option>
                                        <option>河南经济广播</option>
                                    </select>-->
                </li>

                <li>

                    <span style="padding: 0 10px;border-right: 1px solid #eaeaea;">转赠备注</span>

                    <input type="text" name="remark" value=""  placeholder='留下备注'  />
                </li>

                <!--<a href="javascript:;" style="text-align: center; padding-bottom: 20px;width: 100%; display: block;text-decoration: underline;">管理体现方式</a>-->

            </ul>
            <div class="tips">
                <p>提示：</p>
                <p>积分转赠立即到帐，不可撤销，请认真确认</p>
            </div>

        </nav>

        <div class="tx-button">
            <ul>
                <li style="float: left;"><input type="button" name="sendrecord" onclick ='form_submit("2")' value="转赠记录" style='background:#aaa'/></li>

                <li style="float: right;"><input type="button" name="sendscore" onclick='form_submit("1")' value="立即转赠"/></li>
            </ul>
        </div>

    </form>

</div>

<include file="Public:footer" />